package com.hackerrank.challenges.handshake;

import java.util.Scanner;

public class Solution {
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int T = in.nextInt();
		for(int t = 0; t < T; t++) {
			long N = in.nextInt();
			System.out.println(N * (N - 1) / 2);
		}
	}
}
